﻿Imports System
Imports System.IO
Imports ADOConnection

Module ModSecurity
    'Friend gSAName As String = "sa"
    'Friend gSAPassword As String = ""
    'Friend gSQLServer As String = "(local)"
    'Friend gDBName As String = "Kho 706"

    Friend g_objConnFactory As IConnFactory = Nothing

    Friend RegisterOK As Boolean = False
    Friend LoginOK As Boolean = False
    Friend g_UserName As String = "sa"
    Friend g_Password As String = ""
    Friend myConnStr As String = ""

    Friend g_User As CUser = Nothing

    Friend Function GetConnType(ByVal sConnString As String) As String
        Dim sGetConnType As String = ""
        If sConnString.IndexOf("Provider=SQLOLEDB") > -1 Then
            sGetConnType = "SQL"
        Else
            sGetConnType = "OLEDB"
        End If

        Return sGetConnType
    End Function

    'Friend Function InitSQLDMO() As Boolean
    '    Dim KQ As Boolean = False
    '    Try
    '        Dim mConnType As String = GetConnType(myConnStr)
    '        If mConnType = "SQL" Then
    '            gSAName = g_UserName
    '            gSAPassword = g_Password
    '            gSQLServer = CUsers.GetGiaTriThanhPhan(myConnStr, "Data Source")
    '            gDBName = CUsers.GetGiaTriThanhPhan(myConnStr, "Initial Catalog")
    '            KQ = True
    '        End If
    '    Catch ex As Exception
    '    End Try
    '    Return KQ
    'End Function

    Friend Function GetCnnStrFromFile(ByVal pFileSpec As String) As String
        Dim mPassFromFile As String = ""
        Dim mCnnStr As String = ""
        Try
            Dim sr As StreamReader = New StreamReader(pFileSpec)
            Dim line As String
            Do
                line = sr.ReadLine()
                If Not IsNothing(line) Then
                    If line.IndexOf("Provider") > -1 Then
                        mCnnStr = line
                        Exit Do
                    End If
                End If
            Loop Until line Is Nothing
            sr.Close()
        Catch E As Exception
        End Try

        Return mCnnStr
    End Function
End Module
